package cn.pxs.controller;

import cn.pxs.entity.Type;
import cn.pxs.service.TypeService;
import cn.pxs.tools.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/api/type")
public class TypeController {
    @Autowired
    TypeService typeService;

    @RequestMapping("findAll")
    @ResponseBody
    public Map findAll(){
        return Tools.RespJson(200,"",typeService.findAll());
    }

    @RequestMapping("add")
    @ResponseBody
    public Map findByUid(@RequestBody Type type){
        Type t = typeService.add(type);
        return Tools.RespJson(200,"",t);
    }

//    @RequestMapping("delById/{id}")
//    @ResponseBody
//    public Map delById(@PathVariable("id")String id){
//        typeService.delById(id);
//        return Tools.RespJson(200,"",null);
//    }


}
